package com.qdxwx.data.service.book;

import com.qdxwx.data.mapper.book.BookTeacherMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class BookTeacherServiceImpl implements BookTeacherService {

	@Autowired
	private BookTeacherMapper bookTeacherMapper;

	@Override
	public void insert(int bookId, int teacherId) {
		bookTeacherMapper.insertBookTeacher(bookId, teacherId);
	}

	@Override
	public void insert(int bookId, List<Integer> teacherIds) {
		if (teacherIds.size() < 1) return;
		for (int teacherId : teacherIds) {
			insert(bookId, teacherId);
		}
	}

	@Override
	public List<Integer> getTeacherIds(int bookId) {
		return bookTeacherMapper.selectTeacherIdList(bookId);
	}

	@Override
	public void deleteByBookId(int bookId) {
		bookTeacherMapper.deleteByBookId(bookId);
	}

	@Override
	public int countByTeacherId(int id) {
		return bookTeacherMapper.selectCountByTeacherId(id);
	}
}